<?php

namespace App\Listeners;

use App\Helpers\CommTrait;
use App\Http\Controllers\Miniprograme\SubscribeController;
use App\Http\Controllers\Wx\WechatController;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Modules\Manager\Entities\Department;
use Modules\Manager\Entities\Manager;

class ConfimOrderListener
{
    use CommTrait;
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        if($event->type==config('wechat.notify.mini.ConfirmOrder')){
            $order = $event->order;
            // $order->department
            $getDepartment = $this->getManager($order->department);
            $release = new WechatController();
            if($getDepartment->count()>0){
                foreach ($getDepartment as $value){
                    info('已支付通知管理员'.$value);
                    $release->paidOrder($value,$order);
                }
            }
            //$name =   $order->send_employer_nickname;//Department::query()->where('id',$order->department)->value('name');

            // if($order->openid){
            //     (new SubscribeController())->confirm_order($order,'确认接单通知');
            // }

        }
    }
}
